package com.example.sulingorder.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.sulingorder.dao.OrderCommodityDao;
import com.example.sulingorder.entity.OrderCommodityEntity;
import com.example.sulingorder.service.OrderCommodityService;
import com.xiao.sulingpublic.utils.PageUtils;
import com.xiao.sulingpublic.utils.Query;
import com.xiao.sulingpublic.utils.R;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;


@Service("orderCommodityService")
public class OrderCommodityServiceImpl extends ServiceImpl<OrderCommodityDao, OrderCommodityEntity> implements OrderCommodityService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<OrderCommodityEntity> page = this.page(
                new Query<OrderCommodityEntity>().getPage(params),
                new QueryWrapper<OrderCommodityEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public R saveDataBatch(List<OrderCommodityEntity> orderCommodityList) {
        boolean b = this.saveBatch(orderCommodityList);
        if(b){
            return R.ok();
        }
        return R.error();
    }

}